<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2012.03.17.
   装修资讯($$)*/

!defined('Q_PATH') && exit;

class Index_C_Controller extends InitController{

	public function index(){
		// 读取缓存
		Core_Extend::loadCache('slide');
		
		// 读取资讯
		$sCid=trim(Q::G('cid','G'));
		if($sCid){
			$nCid=Jiaju_Extend::getNew($sCid);
			if(!$nCid){
				$this->page404();
			}
			$sPTitle=Model::F_('grouptopiccategory','grouptopiccategory_id=?',$nCid)->getColumn('grouptopiccategory_name');
			if(!$sPTitle){
				$this->page404();
			}
		}else{
			$nCid=0;
			$sPTitle='';
		}

		$arrWhere=array();
		$arrWhere['A.group_id']=303;
		$arrWhere['A.grouptopic_status']=1;
		if($nCid){
			$arrWhere['A.grouptopiccategory_id']=$nCid;
		}

		$nTotal=Model::F_('grouptopic','@A')->where($arrWhere)->getCounts();

		// 分页显示
		$sPageurl='';
		if($nCid){
			$sPageurl='@new~@jiaju://new/'.$sCid.'_{page}';
		}else{
			$sPageurl='@new~@jiaju://list@?page={page}';
		}

		$oPage=Page::RUN($nTotal,10,$sPageurl);

		$arrGrouptopics=Model::F_('grouptopic','@A')
			->setColumns('A.grouptopic_id,A.grouptopic_title,A.create_dateline,A.grouptopic_views,A.grouptopic_thumb,A.grouptopiccategory_id')
			->joinLeft(Q::C('DB_PREFIX').'grouptopiccategory AS C','C.grouptopiccategory_name','A.grouptopiccategory_id=C.grouptopiccategory_id')
			->where($arrWhere)
			->order('A.grouptopic_id DESC')
			->limit($oPage->S(),$oPage->N())
			->getAll();

		Core_Extend::getSeo($this,array(
			'title'=>($sPTitle?$sPTitle.'_':'').$GLOBALS['_option_']['site_name'].'装修资讯新闻_市场观察_质量曝光_明星娱乐_家装网',
			'keywords'=>($sPTitle?$sPTitle.',':'').$GLOBALS['_option_']['site_name'].'装修资讯新闻,市场观察,国际视野,质量曝光,展会活动,设计&消费,品牌动态,明星娱乐,整形塑形,健康生活,亲子,星座',
			'description'=>$GLOBALS['_option_']['site_name'].$sPTitle.'装修资讯网为您提供最全面的装修资讯信息，包括市场观察、国际视野、质量曝光、展会活动、设计&消费、品牌动态、明星娱乐、整形塑形、健康生活、亲子、星座等各方面的资讯信息。',
		),true,false,false);
		
		$this->assign('sPageNavbar',$oPage->P(array('id'=>'pagination','style'=>'li','current'=>'active')));
		$this->assign('arrGrouptopics',$arrGrouptopics);
		$this->assign('nCid',$nCid);
		$this->assign('sCid',$sCid);
		$this->assign('sPTitle',$sPTitle);
		$this->assign('arrSlides',$GLOBALS['_cache_']['slide']);
		$this->display('new+index');
	}

}
